<?php
  include_once('../class_timer.php');
  require_once('./config.php');
  require_once('./tool_benchmark.php');

  $a = array();
  for($i=0;$i<$nb_iter;++$i){
    $a[] = $i;
  }

  function work1($_a){
    $reverse = array();
    $c = count($_a);
    for($i = $c-1; $i >= 0; --$i){
      $reverse[] = $_a[$i];
    }
    return $reverse;
  }

  function work2($_a){
    $reverse = array_reverse($_a);
    return $reverse;
  }

  function work3($_a){
    $c = count($_a);
    $reverse = array_fill(0, $c, 0);
    foreach($_a as $i=>$v){
      $reverse[$c-$i-1] = $v;
    }
    return $reverse;
  }

  $time1 = new Timer();
  $array_functions = array('work1', 'work2', 'work3');
  Tool_benchmark::bench_array_functions($array_functions,$a,$nb_experiences,$time1);
  $array_names = array('for() $array[]', 'array_reverse', 'for() $array[$i]');
  Tool_benchmark::print_info_bench($array_names,$time1);

#print "for() \$array[]   :: average each = $avg[0], total = $sum[0] \n";
#print "array_reverse     :: average_each = $avg[1], total = $sum[1] \n";
#print "for() \$array[\$i] :: average each = $avg[2], total = $sum[2] \n";

?>
